<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>BOM</title>
</head>
<body>
<div onclick="stop()">停止</div>
<script type="text/javascript">

    let interval = function (){
        console.log( new Date() +"函数中的方法执行了") ;
    }
    let x = setInterval( interval , 1000) ;
    function stop(){
        clearInterval( x ) ;
    }
</script>

</body>
</html>